<?php

namespace App\Models\Project;

use Illuminate\Database\Eloquent\SoftDeletes;

class ContractAttachment extends Base
{
    use SoftDeletes;

    protected $table = 'pm_contract_attachments';

    protected $fillable = [
        'contract_id',
        'type',
        'name',
        'file_url',
        'operator_uid',
    ];

    public function setFileUrlAttribute($value)
    {
        $this->attributes['file_url'] = attachment_in($value);
    }

    public function getFileUrlAttribute($value)
    {
        if ($value) {
            return attachment_out($value);
        }
        return null;
    }
}
